package com.robotic.route.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.robotic.common.annotation.Log;
import com.robotic.common.core.controller.BaseController;
import com.robotic.common.core.domain.AjaxResult;
import com.robotic.common.enums.BusinessType;
import com.robotic.route.domain.InspectionRecordDetails;
import com.robotic.route.service.IInspectionRecordDetailsService;
import com.robotic.common.utils.poi.ExcelUtil;
import com.robotic.common.core.page.TableDataInfo;

/**
 * 巡检记录详情Controller
 *
 * @author tian
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/route/details")
public class InspectionRecordDetailsController extends BaseController
{
    @Autowired
    private IInspectionRecordDetailsService inspectionRecordDetailsService;

    /**
     * 查询巡检记录详情列表
     */
    @GetMapping("/list")
    public TableDataInfo list(InspectionRecordDetails inspectionRecordDetails)
    {
        startPage();
        List<InspectionRecordDetails> list = inspectionRecordDetailsService.selectInspectionRecordDetailsList(inspectionRecordDetails);
        return getDataTable(list);
    }



    /**
     * 查询巡检记录详情列表
     */
    @GetMapping("/getList")
    public TableDataInfo getList(InspectionRecordDetails inspectionRecordDetails)
    {
        startPage();
        List<InspectionRecordDetails> list = inspectionRecordDetailsService.getList(inspectionRecordDetails);
        return getDataTable(list);
    }


    /**
     * 查询巡检记录详情列表（异常点位）
     */
    @GetMapping("/getByRecordId")
    public AjaxResult getAlarmByRecordId(InspectionRecordDetails inspectionRecordDetails)
    {
        List<InspectionRecordDetails> list = inspectionRecordDetailsService.getByRecordId(inspectionRecordDetails);
        return AjaxResult.success(list);
    }


    /**
     * 查询巡检记录详情列表（正常点位）
     */
    @GetMapping("/getNormalByRecordId")
    public AjaxResult getNormalByRecordId(InspectionRecordDetails inspectionRecordDetails)
    {
        List<InspectionRecordDetails> list = inspectionRecordDetailsService.getNormalByRecordId(inspectionRecordDetails);
        return AjaxResult.success(list);
    }

    /**
     * 查询巡检记录数量
     */
    @GetMapping("/getNum")
    public AjaxResult getNum(InspectionRecordDetails inspectionRecordDetails)
    {
        Map<String, Object> list = inspectionRecordDetailsService.getNum(inspectionRecordDetails);
        return AjaxResult.success(list);
    }

    /**
     * 导出巡检记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('details:details:export')")
    @Log(title = "巡检记录详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionRecordDetails inspectionRecordDetails)
    {
        List<InspectionRecordDetails> list = inspectionRecordDetailsService.selectInspectionRecordDetailsList(inspectionRecordDetails);
        ExcelUtil<InspectionRecordDetails> util = new ExcelUtil<InspectionRecordDetails>(InspectionRecordDetails.class);
        util.exportExcel(response, list, "巡检记录详情数据");
    }

    /**
     * 获取巡检记录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('details:details:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inspectionRecordDetailsService.selectInspectionRecordDetailsById(id));
    }

    /**
     * 新增巡检记录详情
     */
    @PreAuthorize("@ss.hasPermi('details:details:add')")
    @Log(title = "巡检记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionRecordDetails inspectionRecordDetails)
    {
        return toAjax(inspectionRecordDetailsService.insertInspectionRecordDetails(inspectionRecordDetails));
    }

    /**
     * 修改巡检记录详情
     */
    @Log(title = "巡检记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionRecordDetails inspectionRecordDetails)
    {
        return toAjax(inspectionRecordDetailsService.updateInspectionRecordDetails(inspectionRecordDetails));
    }

    /**
     * 删除巡检记录详情
     */
    @PreAuthorize("@ss.hasPermi('details:details:remove')")
    @Log(title = "巡检记录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inspectionRecordDetailsService.deleteInspectionRecordDetailsByIds(ids));
    }
}
